﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SMA = System.Management.Automation;

namespace RSPowershell
{
    public static class CmdletExtensions
    {

        public static void WriteVerbose(this SMA.Cmdlet cmdlet, string fmt, params object [] items )
        {
            string s = string.Format(fmt,items);
            cmdlet.WriteVerbose(s);
        }

        public static RSPowershell.ReportExecutionService.ReportExecutionService ConnectToReportExecutionService(this SMA.Cmdlet cmdlet)
        {
            cmdlet.WriteVerbose("Connecting To Report Execution Service");
            var rep_exec_svc = new ReportExecutionService.ReportExecutionService();
            rep_exec_svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
            return rep_exec_svc;
        }

        public static RSPowershell.ReportService2005.ReportingService2005 ConnectToReportingService(this SMA.Cmdlet cmdlet)
        {
            cmdlet.WriteVerbose("Connecting To Reporting Service");
            var rep_svc = new ReportService2005.ReportingService2005();
            rep_svc.Credentials = System.Net.CredentialCache.DefaultCredentials;
            return rep_svc;
        }
    }
}
